﻿using BlazorHybrid.Interfaces;
using BlazorHybrid.Wpf.Services;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace BlazorHybrid.Wpf;

public static class Startup
{
    public static IServiceProvider? Services { get; private set; }

    public static void Init()
    {
        var host = Host.CreateDefaultBuilder()
                       .ConfigureServices(WireupServices)
                       .Build();
        Services = host.Services;
    }

    private static void WireupServices(HostBuilderContext context, IServiceCollection services)
    {
        services.AddWpfBlazorWebView();
        services.AddSingleton<IFormFactor, FormFactor>();

#if DEBUG
        services.AddBlazorWebViewDeveloperTools();
        services.AddLogging(c => c.AddDebug());
#endif
    }
}
